package dao.mysql;

import dal.Conexion;
import dal.Configuracion;
import dao.TablaDao;
import dto.Tabla;
import java.sql.ResultSet;
import java.util.Vector;

/**
 *
 * @author Jose Carlos Gutierrez
 */
public class TablaDaoMySQL extends TablaDao {

    @Override
    public Vector<Tabla> selectTodos() {
        Conexion objConexion = Conexion.getOrCreate();
        
        try {
            Vector<Tabla> objVector = new Vector<Tabla>();
            StringBuffer query = new StringBuffer("SHOW TABLES ");
            ResultSet objResultSet = objConexion.ejecutar(query.toString());

            while (objResultSet.next()) {
                String nombreTabla = objResultSet.getString("Tables_in_" + Configuracion.getConfiguracion().getDbName());
                Tabla objTabla = new Tabla(nombreTabla);
                objVector.addElement(objTabla);
            }
            objConexion.desconectar();
            return objVector;
        } catch (Exception e) {
            try {
                e.printStackTrace();
                objConexion.desconectar();
                throw e;
                
            } catch (Exception ex) {
                
            }
        }

        return null;
    }
}
